package com.supor.aiot.common.app.api;

import com.android.baseconfig.base.BaseApiResult;
import com.android.baseconfig.base.DataApiResult;
import com.supor.aiot.common.app.Constants;
import com.supor.aiot.common.entity.DictionaryBean;
import com.supor.aiot.common.entity.FeedbackBean;
import com.supor.aiot.common.entity.LaunchPageBean;
import com.supor.aiot.common.entity.QuestionTypeBean;
import com.supor.aiot.common.entity.UserAgreementBean;
import com.supor.aiot.common.entity.UserInfo;

import java.util.List;
import java.util.Map;

import io.reactivex.rxjava3.core.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;

/**
 * ---------------------------------------------------------------- <br>
 * Copyright (C) 2014-2020, by het, Shenzhen, All rights reserved.  <br>
 * ---------------------------------------------------------------- <br>
 * <p>
 * 描述: UserService <br>
 * 作者: lei <br>
 * 日期: 2020/11/7 <br>
 */
public interface UserService {

    /**
     * 发送短信验证码
     *
     * @param map
     * mobile 手机号码	字符串	11位	中国号码
     * providerId   默认0
     * @return Observable<BaseApiResult>
     */
    // @FormUrlEncoded
    @POST(Constants.OSS_API + "bossTSmsCheck/mobile/")
    Observable<BaseApiResult<String>> sendCaptcha(@Body Map<String, String> map);

    /**
     * 验证码登录
     *
     * @param mobile 手机号码	字符串	11位	中国号码
     * @param CAPTCHA  验证码	字符串	4位	要先调用002接口
     * @param providerId   默认0
     * @return Observable<BaseApiResult>
     */
    // @FormUrlEncoded
    @GET(Constants.OSS_API + "bossTUser/mobilelogin")
    Observable<BaseApiResult<UserInfo>> login(@Query("mobile") String mobile,
                                              @Query("CAPTCHA") String CAPTCHA,
                                              @Query("providerId") String providerId);

    /**
     * 移动一键登录
     *
     * @param operatorType 运营商类型:1:移动
     * @param providerId   默认0
     * @param type         手机平台：1-Android|2-iOS
     * @param token        移动token
     * @return Observable<BaseApiResult>
     */
    // @FormUrlEncoded
    @GET(Constants.OSS_API + "bossTUser/keyToLogin")
    Observable<BaseApiResult<UserInfo>> cmccLogin(@Query("operatorType") String operatorType,
                                                @Query("providerId") String providerId,
                                                @Query("type") String type,
                                                @Query("token") String token);

    /**
     * 退出登录
     *
     * @return Observable<BaseApiResult<>>
     */
    @GET(Constants.OSS_API + "bossTUser/exitLogin")
    Observable<BaseApiResult<String>> logout();

    /**
     *  注销用户
     * @return Observable<BaseApiResult<>>
     */
    @POST(Constants.OSS_API + "bossTUser/del/{bossUserId}")
    Observable<BaseApiResult<String>> deleteUser(@Path("bossUserId") String bossUserId);

    /**
     * 获取用户信息
     *
     * @param id 用户ID
     * @return Observable<BaseApiResult<UserInfo>>
     */
    // @FormUrlEncoded
    @GET(Constants.OSS_API + "bossTUser/{id}")
    Observable<BaseApiResult<UserInfo>> getUser(@Path("id") String id);

    /**
     * 获取会员等级
     *
     * @return Observable<BaseApiResult<>>
     */
    @GET(Constants.OSS_API + "bossTUser/getUserRank")
    Observable<BaseApiResult<String>> getUserRank();

    /**
     * 更新用户
     *
     * @param id 用户ID
     * @param requestBody   requestBody
     * @return Observable<BaseApiResult<UserInfo>>
     */
    // @FormUrlEncoded
    @POST(Constants.OSS_API + "bossTUser/update/{id}")
    Observable<BaseApiResult<UserInfo>> updateUser(@Path("id") String id, @Body RequestBody requestBody);

    /**
     * 获取问题类型
     *
     * @param sysCodeType 默认QUESTION_TYPE
     * @return BaseApiResult<DataApiResult<QuestionTypeBean>>
     */
    @GET(Constants.OSS_API + "possTSysCode/page")
    Observable<BaseApiResult<DataApiResult<List<QuestionTypeBean>>>> getQuestionType(@Query(
            "sysCodeType") String sysCodeType);

    /**
     * 获取数据字典
     *
     * @param sysCodeType 字段类型
     * @return BaseApiResult<DataApiResult<DictionaryBean>>
     */
    @GET(Constants.OSS_API + "possTSysCode/page")
    Observable<BaseApiResult<DataApiResult<List<DictionaryBean>>>> getDictionary(@Query(
            "sysCodeType") String sysCodeType, @Query("page") int page, @Query("limit") int limit);

    /**
     * 反馈
     *
     * @param feedbackBean feedbackBean
     * @return BaseApiResult<String>
     */
    @POST(Constants.OSS_API + "bossTFeedBack/addFeedBack")
    Observable<BaseApiResult<String>> addFeedback(@Body FeedbackBean feedbackBean);

    /**
     * 用户隐私政策
     *
     * @return BaseApiResult<DataApiResult<UserAgreementBean>>
     */
    @GET(Constants.OSS_API + "possTAgreement/page?agreementType=USERPRIVACYAGREE&type=native")
    Observable<BaseApiResult<DataApiResult<List<UserAgreementBean>>>> getUserPrivacyProtocol();

    /**
     * 用户服务协议
     *
     * @return BaseApiResult<DataApiResult<UserAgreementBean>>
     */
    @GET(Constants.OSS_API + "possTAgreement/page?agreementType=USERSERVERAGREE&type=native")
    Observable<BaseApiResult<DataApiResult<List<UserAgreementBean>>>> getUserServerProtocol();

    /**
     * 广告图url获取
     *
     * @return BaseApiResult<DataApiResult<LaunchPageBean>>
     */
    @GET(Constants.OSS_API + "bossTFont/getPicture")
    Observable<BaseApiResult<List<LaunchPageBean>>> getLaunchPageUrl();

    /**
     * 广告图url获取
     *
     * @param map
     * @return BaseApiResult<DataApiResult<LaunchPageBean>>
     */
    @GET(Constants.OSS_API + "bossTFont/getPicture")
    Observable<BaseApiResult<List<LaunchPageBean>>> getLaunchPageUrl(@QueryMap() Map<String, String> map);

    /**
     * 上传设备token
     *
     * @param requestBody requestBody
     * @return Observable<BaseApiResult<String>>
     */
    // @FormUrlEncoded
    @POST(Constants.OSS_API + "device/pushAppToken")
    Observable<BaseApiResult<String>> pushAppToken(@Body RequestBody requestBody);
}
